var htmlstr=new Array();
function initData(page_index) {
$.ajax({
		url : $("#Pagination").attr("url"),
		type : "post",
		cache : false,
		data : {
			currentPage : page_index,
			pageSize : $("#Pagination").attr("pageSize"),
			type: $("#type").val(),
			username: $("#username").val(),
			beginDate:$("#dpd1").val(),
			endDate:$("#dpd2").val(),
			status:$("#status").val()
		},
		success : function(data) {
			var json=eval("("+data+")");
			$("#Pagination").attr("recordCount",json.page.recordCount);
			$("#expTable").empty(); 			
			var str='';
			var url='';
			for(var i=0;i<json.accuse.length;i++){
				if(json.accuse[i].channel=='问答'){
					url='viewAccuse?itemid='+json.accuse[i].itemid+'&accsueid='+json.accuse[i].accuseid+'&channel=ask';
				}
				htmlstr[i]='<p>检举人:'+json.accuse[i].username+'</p>'
				       +'<p>检举栏目:'+json.accuse[i].channel+'</p>'
				       +'<p>检举说明:'+formatVal(json.accuse[i].accusedesc)+'</p>'
				       +'<p>检举类别:'+json.accuse[i].typename+'</p>'
				       +'<p>检举时间:'+json.accuse[i].creatdate+'</p>'
				       +'<p>检举链接:'+'<a target="_blank" href="'+url+'">点我查看</a>'+'</p>'
				       +'<p>检举内容:'+formatVal(json.accuse[i].acont)+'</p>'
				       +'<p>检举状态:'+showStatus(json.accuse[i].status)+'</p>';
				str+='<tr><td><input type="checkbox" class="checkboxes" value="'+json.accuse[i].accuseid+'" ></td><td>'+json.accuse[i].typename+'</td><td>'+(json.accuse[i].creatdate).substring(0,10)
				     +'</td><td>'+json.accuse[i].username
				     +'</td><td>'+'<a target="_blank" href="'+url+'">点我查看</a>'
				     +'</td><td>'+showStatus(json.accuse[i].status)
				     +'</td><td><a onclick="view('+i+')">查看</a> | '
				     +'<a type="'+json.accuse[i].accuseid+'" onclick="del(this)">删除</a></td></tr>';
			}
			$("#expTable").append(str);
			$.fn.refreshPagination(page_index);
		},
		error : function(xhr) {
			alert("点击过快，正在加载，请稍后再次点击!"+xhr.statusText);
		}
	});
	jQuery('#sample_1 .group-checkable').attr("checked", false);
}

function view(i){
	$("#my-comment").html(htmlstr[i]);
	$('#myModal').modal();
}

function showStatus(obj){
   if(obj==0){
   	  return '未解决';
   }else if(obj==1){
   	 return '已解决';
   }
}

function del(obj){
	if(confirm("确认要删除吗?")){
		$.post("delAccuse", { id: obj.type},function(data){
			initData(1);
		});
	}
}